package com.zjut.zs.applyview.dao;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.zjut.an.util.module.PageModule;
import com.zjut.an.util.tools.AESUtils;


/**
 * A data access object (DAO) providing persistence and search support for
 * ZsApplyView entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.zjut.zs.applyview.dao.ZsApplyView
 * @author MyEclipse Persistence Tools
 */

public class ZsApplyViewDAO extends HibernateDaoSupport {
	private static final Logger log = LoggerFactory
			.getLogger(ZsApplyViewDAO.class);
	// property constants
	public static final String US_ID = "usId";
	public static final String US_BMXH = "usBmxh";
	public static final String US_NAME = "usName";
	public static final String US_IDCARD = "usIdcard";
	public static final String US_PASSWORD = "usPassword";
	public static final String US_EMAIL = "usEmail";
	public static final String US_MOBILE = "usMobile";
	public static final String ADD_TIME = "addTime";
	public static final String EDIT_TIME = "editTime";
	public static final String LOGIN_TIME = "loginTime";
	public static final String OPEN_ID = "openId";
	public static final String WX_NAME = "wxName";
	public static final String WX_ICON = "wxIcon";
	public static final String US_ACTIVE = "usActive";
	public static final String US_YUN = "usYun";
	public static final String USS_ID = "ussId";
	public static final String SC_ID = "scId";
	public static final String SC_CODE = "scCode";
	public static final String YEAR = "year";
	public static final String APP_STATUS = "appStatus";
	public static final String SEND_STATUS = "sendStatus";
	public static final String APP_TIME = "appTime";
	public static final String SEND_TIME = "sendTime";
	public static final String CHECK_STATUS = "checkStatus";
	public static final String CHECK_TIME = "checkTime";
	public static final String PAY_STATUS = "payStatus";
	public static final String PAY_TIME = "payTime";
	public static final String PASS_STATUS = "passStatus";
	public static final String PASS_TIME = "passTime";
	public static final String TEST_NO = "testNo";
	public static final String TEST_NUM = "testNum";
	public static final String EX_ID = "exId";
	public static final String EXV_ID = "exvId";
	public static final String COLUMN1 = "column1";
	public static final String COLUMN2 = "column2";
	public static final String COLUMN3 = "column3";
	public static final String COLUMN4 = "column4";
	public static final String COLUMN5 = "column5";
	public static final String COLUMN6 = "column6";
	public static final String COLUMN7 = "column7";
	public static final String COLUMN8 = "column8";
	public static final String COLUMN9 = "column9";
	public static final String COLUMN10 = "column10";
	public static final String LOCAL_STATUS = "localStatus";
	public static final String MESSAGE = "message";
	public static final String EMS_NUM = "emsNum";
	public static final String EMS_STATUS = "emsStatus";
	public static final String EMS_TIME = "emsTime";
	public static final String TEST_MNUM = "testMnum";
	public static final String TEST_BNUM = "testBnum";
	public static final String IN_MZ = "inMz";
	public static final String IN_ID = "inId";
	public static final String IN_PHOTO = "inPhoto";
	public static final String IN_PINYING = "inPinying";
	public static final String SC_COLUMN1 = "scColumn1";
	public static final String SC_COLUMN2 = "scColumn2";
	public static final String SC_COLUMN3 = "scColumn3";
	public static final String SC_COLUMN4 = "scColumn4";
	public static final String SC_COLUMN5 = "scColumn5";
	public static final String SC_COLUMN6 = "scColumn6";
	public static final String SC_COLUMN7 = "scColumn7";
	public static final String SC_COLUMN8 = "scColumn8";
	public static final String SC_COLUMN9 = "scColumn9";
	public static final String SC_COLUMN10 = "scColumn10";
	public static final String FILE_STATUS = "fileStatus";
	public static final String FILE_TIME = "fileTime";
	public static final String FILE_CHECK_STATUS = "fileCheckStatus";
	public static final String ZS_ZXLB = "zsZxlb";
	public static final String ZS_SHHD = "zsShhd";
	public static final String ZS_HJQK = "zsHjqk";
	public static final String US_NO = "usNo";
	public static final String CHECK_REMARK = "checkRemark";
	public static final String PASS_REMARK = "passRemark";
	public static final String IN_BYXXMC = "inByxxmc";
	public static final String IN_BYLB = "inBylb";
	public static final String IN_XB = "inXb";
	public static final String IN_KSLB = "inKslb";
	public static final String IN_ZZMM = "inZzmm";
	public static final String IN_ZJLX = "inZjlx";
	public static final String IN_ZJHM = "inZjhm";
	public static final String IN_HJMC = "inHjmc";
	public static final String IN_LXDH = "inLxdh";
	public static final String IN_LXDH2 = "inLxdh2";
	public static final String IN_KL = "inKl";
	public static final String IN_WYYZ = "inWyyz";
	public static final String IN_SDMC = "inSdmc";
	public static final String IN_SXMC = "inSxmc";
	public static final String IN_BMDMC = "inBmdmc";
	public static final String IN_BRTC = "inBrtc";
	public static final String IN_BZ = "inBz";
	public static final String IN_ZSQK = "inZsqk";
	public static final String IN_HJQK = "inHjqk";
	public static final String IN_XKKM = "inXkkm";
	public static final String IN_XXBZ1 = "inXxbz1";
	public static final String IN_XXBZ2 = "inXxbz2";
	public static final String IN_XXBZ3 = "inXxbz3";
	public static final String IN_ZYDM01 = "inZydm01";
	public static final String IN_ZYMC01 = "inZymc01";
	public static final String IN_ZYDM02 = "inZydm02";
	public static final String IN_ZYMC02 = "inZymc02";
	public static final String IN_ZYDM03 = "inZydm03";
	public static final String IN_ZYMC03 = "inZymc03";
	public static final String IN_ZYDM04 = "inZydm04";
	public static final String IN_ZYMC04 = "inZymc04";
	public static final String IN_ZYDM05 = "inZydm05";
	public static final String IN_ZYMC05 = "inZymc05";
	public static final String IN_ZYDM06 = "inZydm06";
	public static final String IN_ZYMC06 = "inZymc06";
	public static final String IN_ZYDM07 = "inZydm07";
	public static final String IN_ZYMC07 = "inZymc07";
	public static final String IN_ZYDM08 = "inZydm08";
	public static final String IN_ZYMC08 = "inZymc08";
	public static final String IN_ZYDM09 = "inZydm09";
	public static final String IN_ZYMC09 = "inZymc09";
	public static final String IN_ZYDM10 = "inZydm10";
	public static final String IN_ZYMC10 = "inZymc10";
	public static final String IN_ZYFC = "inZyfc";
	public static final String IN_YWDD = "inYwdd";
	public static final String IN_SXDD = "inSxdd";
	public static final String IN_WYDD = "inWydd";
	public static final String IN_ZZDD = "inZzdd";
	public static final String IN_LSDD = "inLsdd";
	public static final String IN_DLDD = "inDldd";
	public static final String IN_WLDD = "inWldd";
	public static final String IN_HXDD = "inHxdd";
	public static final String IN_SWDD = "inSwdd";
	public static final String IN_JSDD = "inJsdd";
	public static final String IN_XXDD = "inXxdd";
	public static final String IN_TYDD = "inTydd";
	public static final String IN_YKXKKM = "inYkxkkm";
	public static final String IN_PDBX = "inPdbx";
	public static final String IN_YDJK = "inYdjk";
	public static final String IN_YSSY = "inYssy";
	public static final String IN_CXSJ = "inCxsj";
	public static final String PRINT_STATUS = "printStatus";
	protected void initDao() {
		// do nothing
	}

	public void save(ZsApplyView transientInstance) {
		log.debug("saving ZsApplyView instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public void sort(Criteria criteria, String sort, String order) {
		if (sort!=null && order!=null) {
			if (order.equals("asc")) {
				criteria.addOrder(Order.asc(sort));
			} else {
				criteria.addOrder(Order.desc(sort));
			}
		} else {
			criteria.addOrder(Order.desc(US_ID));			
		}
	}

	public void delete(ZsApplyView persistentInstance) {
		log.debug("deleting ZsApplyView instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public ZsApplyView findById(java.lang.String id) {
		log.debug("getting ZsApplyView instance with id: " + id);
		try {
			ZsApplyView instance = (ZsApplyView) getHibernateTemplate().get(
					"com.zjut.zs.applyview.dao.ZsApplyView", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(ZsApplyView instance) {
		log.debug("finding ZsApplyView instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding ZsApplyView instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from ZsApplyView as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByUsName(Object usName) {
		return findByProperty(US_NAME, usName);
	}

	public List findByUsIdcard(Object usIdcard) {
		return findByProperty(US_IDCARD, usIdcard);
	}

	public List findByUsPassword(Object usPassword) {
		return findByProperty(US_PASSWORD, usPassword);
	}

	public List findByUsEmail(Object usEmail) {
		return findByProperty(US_EMAIL, usEmail);
	}

	public List findByUsMobile(Object usMobile) {
		return findByProperty(US_MOBILE, usMobile);
	}

	public List findByAddTime(Object addTime) {
		return findByProperty(ADD_TIME, addTime);
	}

	public List findByEditTime(Object editTime) {
		return findByProperty(EDIT_TIME, editTime);
	}

	public List findByLoginTime(Object loginTime) {
		return findByProperty(LOGIN_TIME, loginTime);
	}

	public List findByOpenId(Object openId) {
		return findByProperty(OPEN_ID, openId);
	}

	public List findByWxName(Object wxName) {
		return findByProperty(WX_NAME, wxName);
	}

	public List findByWxIcon(Object wxIcon) {
		return findByProperty(WX_ICON, wxIcon);
	}

	public List findByUsActive(Object usActive) {
		return findByProperty(US_ACTIVE, usActive);
	}

	public List findByUsYun(Object usYun) {
		return findByProperty(US_YUN, usYun);
	}

	public List findByUssId(Object ussId) {
		return findByProperty(USS_ID, ussId);
	}

	public List findByScId(Object scId) {
		return findByProperty(SC_ID, scId);
	}

	public List findByScCode(Object scCode) {
		return findByProperty(SC_CODE, scCode);
	}

	public List findByYear(Object year) {
		return findByProperty(YEAR, year);
	}

	public List findByAppStatus(Object appStatus) {
		return findByProperty(APP_STATUS, appStatus);
	}

	public List findBySendStatus(Object sendStatus) {
		return findByProperty(SEND_STATUS, sendStatus);
	}

	public List findByAppTime(Object appTime) {
		return findByProperty(APP_TIME, appTime);
	}

	public List findBySendTime(Object sendTime) {
		return findByProperty(SEND_TIME, sendTime);
	}

	public List findByCheckStatus(Object checkStatus) {
		return findByProperty(CHECK_STATUS, checkStatus);
	}

	public List findByCheckTime(Object checkTime) {
		return findByProperty(CHECK_TIME, checkTime);
	}

	public List findByPayStatus(Object payStatus) {
		return findByProperty(PAY_STATUS, payStatus);
	}

	public List findByPayTime(Object payTime) {
		return findByProperty(PAY_TIME, payTime);
	}

	public List findByPassStatus(Object passStatus) {
		return findByProperty(PASS_STATUS, passStatus);
	}

	public List findByPassTime(Object passTime) {
		return findByProperty(PASS_TIME, passTime);
	}

	public List findByTestNo(Object testNo) {
		return findByProperty(TEST_NO, testNo);
	}

	public List findByTestNum(Object testNum) {
		return findByProperty(TEST_NUM, testNum);
	}

	public List findByExId(Object exId) {
		return findByProperty(EX_ID, exId);
	}
	
	public List findByExvId(Object exvId) {
		return findByProperty(EXV_ID, exvId);
	}

	public List findByColumn1(Object column1) {
		return findByProperty(COLUMN1, column1);
	}

	public List findByColumn2(Object column2) {
		return findByProperty(COLUMN2, column2);
	}

	public List findByColumn3(Object column3) {
		return findByProperty(COLUMN3, column3);
	}

	public List findByColumn4(Object column4) {
		return findByProperty(COLUMN4, column4);
	}

	public List findByColumn5(Object column5) {
		return findByProperty(COLUMN5, column5);
	}

	public List findByColumn6(Object column6) {
		return findByProperty(COLUMN6, column6);
	}

	public List findByColumn7(Object column7) {
		return findByProperty(COLUMN7, column7);
	}

	public List findByColumn8(Object column8) {
		return findByProperty(COLUMN8, column8);
	}

	public List findByColumn9(Object column9) {
		return findByProperty(COLUMN9, column9);
	}

	public List findByColumn10(Object column10) {
		return findByProperty(COLUMN10, column10);
	}

	public List findByLocalStatus(Object localStatus) {
		return findByProperty(LOCAL_STATUS, localStatus);
	}

	public List findByMessage(Object message) {
		return findByProperty(MESSAGE, message);
	}

	public List findByEmsNum(Object emsNum) {
		return findByProperty(EMS_NUM, emsNum);
	}

	public List findByEmsStatus(Object emsStatus) {
		return findByProperty(EMS_STATUS, emsStatus);
	}

	public List findByEmsTime(Object emsTime) {
		return findByProperty(EMS_TIME, emsTime);
	}

	public List findByTestMnum(Object testMnum) {
		return findByProperty(TEST_MNUM, testMnum);
	}

	public List findByTestBnum(Object testBnum) {
		return findByProperty(TEST_BNUM, testBnum);
	}

	public List findByInMz(Object inMz) {
		return findByProperty(IN_MZ, inMz);
	}

	public List findByInId(Object inId) {
		return findByProperty(IN_ID, inId);
	}

	public List findByInPhoto(Object inPhoto) {
		return findByProperty(IN_PHOTO, inPhoto);
	}

	public List findByInPinying(Object inPinying) {
		return findByProperty(IN_PINYING, inPinying);
	}

	public List findByScColumn1(Object scColumn1) {
		return findByProperty(SC_COLUMN1, scColumn1);
	}

	public List findByScColumn2(Object scColumn2) {
		return findByProperty(SC_COLUMN2, scColumn2);
	}

	public List findByScColumn3(Object scColumn3) {
		return findByProperty(SC_COLUMN3, scColumn3);
	}

	public List findByScColumn4(Object scColumn4) {
		return findByProperty(SC_COLUMN4, scColumn4);
	}

	public List findByScColumn5(Object scColumn5) {
		return findByProperty(SC_COLUMN5, scColumn5);
	}

	public List findByScColumn6(Object scColumn6) {
		return findByProperty(SC_COLUMN6, scColumn6);
	}

	public List findByScColumn7(Object scColumn7) {
		return findByProperty(SC_COLUMN7, scColumn7);
	}

	public List findByScColumn8(Object scColumn8) {
		return findByProperty(SC_COLUMN8, scColumn8);
	}

	public List findByScColumn9(Object scColumn9) {
		return findByProperty(SC_COLUMN9, scColumn9);
	}

	public List findByScColumn10(Object scColumn10) {
		return findByProperty(SC_COLUMN10, scColumn10);
	}

	public List findByFileStatus(Object fileStatus) {
		return findByProperty(FILE_STATUS, fileStatus);
	}

	public List findByFileTime(Object fileTime) {
		return findByProperty(FILE_TIME, fileTime);
	}

	public List findByFileCheckStatus(Object fileCheckStatus) {
		return findByProperty(FILE_CHECK_STATUS, fileCheckStatus);
	}

	public List findByZsZxlb(Object zsZxlb) {
		return findByProperty(ZS_ZXLB, zsZxlb);
	}

	public List findByZsShhd(Object zsShhd) {
		return findByProperty(ZS_SHHD, zsShhd);
	}

	public List findByZsHjqk(Object zsHjqk) {
		return findByProperty(ZS_HJQK, zsHjqk);
	}

	public List findByUsNo(Object usNo) {
		return findByProperty(US_NO, usNo);
	}

	public List findByCheckRemark(Object checkRemark) {
		return findByProperty(CHECK_REMARK, checkRemark);
	}

	public List findByPassRemark(Object passRemark) {
		return findByProperty(PASS_REMARK, passRemark);
	}

	public List findByInByxxmc(Object inByxxmc) {
		return findByProperty(IN_BYXXMC, inByxxmc);
	}

	public List findByInBylb(Object inBylb) {
		return findByProperty(IN_BYLB, inBylb);
	}

	public List findByInXb(Object inXb) {
		return findByProperty(IN_XB, inXb);
	}

	public List findByInKslb(Object inKslb) {
		return findByProperty(IN_KSLB, inKslb);
	}

	public List findByInZzmm(Object inZzmm) {
		return findByProperty(IN_ZZMM, inZzmm);
	}

	public List findByInZjlx(Object inZjlx) {
		return findByProperty(IN_ZJLX, inZjlx);
	}

	public List findByInZjhm(Object inZjhm) {
		return findByProperty(IN_ZJHM, inZjhm);
	}

	public List findByInHjmc(Object inHjmc) {
		return findByProperty(IN_HJMC, inHjmc);
	}

	public List findByInLxdh(Object inLxdh) {
		return findByProperty(IN_LXDH, inLxdh);
	}

	public List findByInLxdh2(Object inLxdh2) {
		return findByProperty(IN_LXDH2, inLxdh2);
	}

	public List findByInKl(Object inKl) {
		return findByProperty(IN_KL, inKl);
	}

	public List findByInWyyz(Object inWyyz) {
		return findByProperty(IN_WYYZ, inWyyz);
	}

	public List findByInSdmc(Object inSdmc) {
		return findByProperty(IN_SDMC, inSdmc);
	}

	public List findByInSxmc(Object inSxmc) {
		return findByProperty(IN_SXMC, inSxmc);
	}

	public List findByInBmdmc(Object inBmdmc) {
		return findByProperty(IN_BMDMC, inBmdmc);
	}

	public List findByInBrtc(Object inBrtc) {
		return findByProperty(IN_BRTC, inBrtc);
	}

	public List findByInBz(Object inBz) {
		return findByProperty(IN_BZ, inBz);
	}

	public List findByInZsqk(Object inZsqk) {
		return findByProperty(IN_ZSQK, inZsqk);
	}

	public List findByInHjqk(Object inHjqk) {
		return findByProperty(IN_HJQK, inHjqk);
	}

	public List findByInXkkm(Object inXkkm) {
		return findByProperty(IN_XKKM, inXkkm);
	}

	public List findByInXxbz1(Object inXxbz1) {
		return findByProperty(IN_XXBZ1, inXxbz1);
	}

	public List findByInXxbz2(Object inXxbz2) {
		return findByProperty(IN_XXBZ2, inXxbz2);
	}

	public List findByInXxbz3(Object inXxbz3) {
		return findByProperty(IN_XXBZ3, inXxbz3);
	}

	public List findByInZydm01(Object inZydm01) {
		return findByProperty(IN_ZYDM01, inZydm01);
	}

	public List findByInZymc01(Object inZymc01) {
		return findByProperty(IN_ZYMC01, inZymc01);
	}

	public List findByInZydm02(Object inZydm02) {
		return findByProperty(IN_ZYDM02, inZydm02);
	}

	public List findByInZymc02(Object inZymc02) {
		return findByProperty(IN_ZYMC02, inZymc02);
	}

	public List findByInZydm03(Object inZydm03) {
		return findByProperty(IN_ZYDM03, inZydm03);
	}

	public List findByInZymc03(Object inZymc03) {
		return findByProperty(IN_ZYMC03, inZymc03);
	}

	public List findByInZydm04(Object inZydm04) {
		return findByProperty(IN_ZYDM04, inZydm04);
	}

	public List findByInZymc04(Object inZymc04) {
		return findByProperty(IN_ZYMC04, inZymc04);
	}

	public List findByInZydm05(Object inZydm05) {
		return findByProperty(IN_ZYDM05, inZydm05);
	}

	public List findByInZymc05(Object inZymc05) {
		return findByProperty(IN_ZYMC05, inZymc05);
	}

	public List findByInZydm06(Object inZydm06) {
		return findByProperty(IN_ZYDM06, inZydm06);
	}

	public List findByInZymc06(Object inZymc06) {
		return findByProperty(IN_ZYMC06, inZymc06);
	}

	public List findByInZydm07(Object inZydm07) {
		return findByProperty(IN_ZYDM07, inZydm07);
	}

	public List findByInZymc07(Object inZymc07) {
		return findByProperty(IN_ZYMC07, inZymc07);
	}

	public List findByInZydm08(Object inZydm08) {
		return findByProperty(IN_ZYDM08, inZydm08);
	}

	public List findByInZymc08(Object inZymc08) {
		return findByProperty(IN_ZYMC08, inZymc08);
	}

	public List findByInZydm09(Object inZydm09) {
		return findByProperty(IN_ZYDM09, inZydm09);
	}

	public List findByInZymc09(Object inZymc09) {
		return findByProperty(IN_ZYMC09, inZymc09);
	}

	public List findByInZydm10(Object inZydm10) {
		return findByProperty(IN_ZYDM10, inZydm10);
	}

	public List findByInZymc10(Object inZymc10) {
		return findByProperty(IN_ZYMC10, inZymc10);
	}

	public List findByInZyfc(Object inZyfc) {
		return findByProperty(IN_ZYFC, inZyfc);
	}

	public List findByInYwdd(Object inYwdd) {
		return findByProperty(IN_YWDD, inYwdd);
	}

	public List findByInSxdd(Object inSxdd) {
		return findByProperty(IN_SXDD, inSxdd);
	}

	public List findByInWydd(Object inWydd) {
		return findByProperty(IN_WYDD, inWydd);
	}

	public List findByInZzdd(Object inZzdd) {
		return findByProperty(IN_ZZDD, inZzdd);
	}

	public List findByInLsdd(Object inLsdd) {
		return findByProperty(IN_LSDD, inLsdd);
	}

	public List findByInDldd(Object inDldd) {
		return findByProperty(IN_DLDD, inDldd);
	}

	public List findByInWldd(Object inWldd) {
		return findByProperty(IN_WLDD, inWldd);
	}

	public List findByInHxdd(Object inHxdd) {
		return findByProperty(IN_HXDD, inHxdd);
	}

	public List findByInSwdd(Object inSwdd) {
		return findByProperty(IN_SWDD, inSwdd);
	}

	public List findByInJsdd(Object inJsdd) {
		return findByProperty(IN_JSDD, inJsdd);
	}

	public List findByInXxdd(Object inXxdd) {
		return findByProperty(IN_XXDD, inXxdd);
	}

	public List findByInTydd(Object inTydd) {
		return findByProperty(IN_TYDD, inTydd);
	}

	public List findByInYkxkkm(Object inYkxkkm) {
		return findByProperty(IN_YKXKKM, inYkxkkm);
	}

	public List findByInPdbx(Object inPdbx) {
		return findByProperty(IN_PDBX, inPdbx);
	}

	public List findByInYdjk(Object inYdjk) {
		return findByProperty(IN_YDJK, inYdjk);
	}

	public List findByInYssy(Object inYssy) {
		return findByProperty(IN_YSSY, inYssy);
	}

	public List findByInCxsj(Object inCxsj) {
		return findByProperty(IN_CXSJ, inCxsj);
	}

	public List findAll() {
		log.debug("finding all ZsApplyView instances");
		try {
			String queryString = "from ZsApplyView";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public ZsApplyView merge(ZsApplyView detachedInstance) {
		log.debug("merging ZsApplyView instance");
		try {
			ZsApplyView result = (ZsApplyView) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(ZsApplyView instance) {
		log.debug("attaching dirty ZsApplyView instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(ZsApplyView instance) {
		log.debug("attaching clean ZsApplyView instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static ZsApplyViewDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (ZsApplyViewDAO) ctx.getBean("ZsApplyViewDAO");
	}

	@SuppressWarnings("unchecked")
	public PageModule findByInstance(final int pageNumber ,final int pageSize, String sort, String order, final ZsApplyView obj){
		try {
			int startIndex = (pageNumber - 1) * pageSize;
			Session session = getHibernateTemplate().getSessionFactory().openSession();
			List list;
			Criteria criteria = session.createCriteria(ZsApplyView.class);
			
			if (!isEmpty(obj.getUsId())) {
				criteria.add(Restrictions.eq(US_ID, obj.getUsId()));
			}
			if (!isEmpty(obj.getUsName())) {
				String name = AESUtils.AESEncryptDemo(obj.getUsName());
				criteria.add(Restrictions.eq(US_NAME, name));
			}
			if (!isEmpty(obj.getUsBmxh())) {
				criteria.add(Restrictions.like(US_BMXH, obj.getUsBmxh(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getInXb())) {
				criteria.add(Restrictions.like(IN_XB, obj.getInXb(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsNo())) {
				criteria.add(Restrictions.like(US_NO, obj.getUsNo(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsIdcard())) {
				criteria.add(Restrictions.like(US_IDCARD, obj.getUsIdcard(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsPassword())) {
				criteria.add(Restrictions.eq(US_PASSWORD, obj.getUsPassword()));
			}
			if (!isEmpty(obj.getUsEmail())) {
				criteria.add(Restrictions.eq(US_EMAIL, obj.getUsEmail()));
			}
			if (!isEmpty(obj.getUsMobile())) {
				criteria.add(Restrictions.eq(US_MOBILE, obj.getUsMobile()));
			}
			if (!isEmpty(obj.getOpenId())) {
				criteria.add(Restrictions.eq(OPEN_ID, obj.getOpenId()));
			}
			if (!isEmpty(obj.getWxName())) {
				criteria.add(Restrictions.eq(WX_NAME, obj.getWxName()));
			}
			if (!isEmpty(obj.getWxIcon())) {
				criteria.add(Restrictions.eq(WX_ICON, obj.getWxIcon()));
			}
			if (!isEmpty(obj.getUsActive())) {
				criteria.add(Restrictions.eq(US_ACTIVE, obj.getUsActive()));
			}
			if (!isEmpty(obj.getUsYun())) {
				criteria.add(Restrictions.eq(US_YUN, obj.getUsYun()));
			}
			if (null != obj.getYear()) {
				criteria.add(Restrictions.eq(YEAR, obj.getYear()));
			}
			if (!isEmpty(obj.getAppStatus())) {
				criteria.add(Restrictions.eq(APP_STATUS, obj.getAppStatus()));
			}
			if (!isEmpty(obj.getSendStatus())) {
				criteria.add(Restrictions.eq(SEND_STATUS, obj.getSendStatus()));
			}
			if (!isEmpty(obj.getCheckStatus())) {
				criteria.add(Restrictions.eq(CHECK_STATUS, obj.getCheckStatus()));
			}
			if (!isEmpty(obj.getPayStatus())) {
				criteria.add(Restrictions.eq(PAY_STATUS, obj.getPayStatus()));
			}
			if (!isEmpty(obj.getPassStatus())) {
				criteria.add(Restrictions.eq(PASS_STATUS, obj.getPassStatus()));
			}
			if (!isEmpty(obj.getLocalStatus())) {
				criteria.add(Restrictions.eq(LOCAL_STATUS, obj.getLocalStatus()));
			}
			if (!isEmpty(obj.getFileStatus())) {
				criteria.add(Restrictions.eq(FILE_STATUS, obj.getFileStatus()));
			}
			if (!isEmpty(obj.getFileCheckStatus())) {
				criteria.add(Restrictions.eq(FILE_CHECK_STATUS, obj.getFileCheckStatus()));
			}
			if (!isEmpty(obj.getTestNo())) {
				criteria.add(Restrictions.like(TEST_NO, obj.getTestNo(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getTestNum())) {
				criteria.add(Restrictions.like(TEST_NUM, obj.getTestNum(),MatchMode.ANYWHERE));
			}
			if (null != obj.getExId()) {
				criteria.add(Restrictions.eq(EX_ID, obj.getExId()));
			}
			if (!isEmpty(obj.getColumn1())) {
				criteria.add(Restrictions.eq(COLUMN1, obj.getColumn1()));
			}
			if (!isEmpty(obj.getColumn2())) {
				criteria.add(Restrictions.eq(COLUMN2, obj.getColumn2()));
			}
			if (!isEmpty(obj.getColumn3())) {
				criteria.add(Restrictions.eq(COLUMN3, obj.getColumn3()));
			}
			if (!isEmpty(obj.getColumn4())) {
				criteria.add(Restrictions.eq(COLUMN4, obj.getColumn4()));
			}
			if (!isEmpty(obj.getColumn5())) {
				criteria.add(Restrictions.eq(COLUMN5, obj.getColumn5()));
			}
			if (!isEmpty(obj.getColumn6())) {
				criteria.add(Restrictions.eq(COLUMN6, obj.getColumn6()));
			}
			if (!isEmpty(obj.getColumn7())) {
				criteria.add(Restrictions.eq(COLUMN7, obj.getColumn7()));
			}
			if (!isEmpty(obj.getColumn8())) {
				criteria.add(Restrictions.eq(COLUMN8, obj.getColumn8()));
			}
			if (!isEmpty(obj.getColumn9())) {
				criteria.add(Restrictions.eq(COLUMN9, obj.getColumn9()));
			}
			if (!isEmpty(obj.getColumn10())) {
				criteria.add(Restrictions.eq(COLUMN10, obj.getColumn10()));
			}
			if (!isEmpty(obj.getInLxdh())) {
				criteria.add(Restrictions.eq(IN_LXDH, obj.getInLxdh()));
			}
			if (!isEmpty(obj.getInLxdh2())) {
				criteria.add(Restrictions.eq(IN_LXDH2, obj.getInLxdh2()));
			}
			if (!isEmpty(obj.getInZymc01())) {
				criteria.add(Restrictions.eq(IN_ZYMC01, obj.getInZymc01()));
			}
			if (!isEmpty(obj.getInZymc02())) {
				criteria.add(Restrictions.eq(IN_ZYMC02, obj.getInZymc02()));
			}
			if (!isEmpty(obj.getInZymc03())) {
				criteria.add(Restrictions.eq(IN_ZYMC03, obj.getInZymc03()));
			}
			if (!isEmpty(obj.getInZymc04())) {
				criteria.add(Restrictions.eq(IN_ZYMC04, obj.getInZymc04()));
			}
			if (!isEmpty(obj.getInZymc05())) {
				criteria.add(Restrictions.eq(IN_ZYMC05, obj.getInZymc05()));
			}
			if (!isEmpty(obj.getInZymc06())) {
				criteria.add(Restrictions.eq(IN_ZYMC06, obj.getInZymc06()));
			}
			if (!isEmpty(obj.getInZymc07())) {
				criteria.add(Restrictions.eq(IN_ZYMC07, obj.getInZymc07()));
			}
			if (!isEmpty(obj.getInZymc08())) {
				criteria.add(Restrictions.eq(IN_ZYMC08, obj.getInZymc08()));
			}
			if (!isEmpty(obj.getInZymc09())) {
				criteria.add(Restrictions.eq(IN_ZYMC09, obj.getInZymc09()));
			}
			if (!isEmpty(obj.getInZymc10())) {
				criteria.add(Restrictions.eq(IN_ZYMC10, obj.getInZymc10()));
			}

			if (!isEmpty(obj.getScColumn1())) {
				criteria.add(Restrictions.like(SC_COLUMN1, obj.getScColumn1(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn2())) {
				criteria.add(Restrictions.like(SC_COLUMN2, obj.getScColumn2(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn3())) {
				criteria.add(Restrictions.like(SC_COLUMN3, obj.getScColumn3(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn4())) {
				criteria.add(Restrictions.like(SC_COLUMN4, obj.getScColumn4(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn5())) {
				criteria.add(Restrictions.like(SC_COLUMN5, obj.getScColumn5(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn6())) {
				criteria.add(Restrictions.like(SC_COLUMN6, obj.getScColumn6(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn7())) {
				criteria.add(Restrictions.like(SC_COLUMN7, obj.getScColumn7(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn8())) {
				criteria.add(Restrictions.like(SC_COLUMN8, obj.getScColumn8(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn9())) {
				criteria.add(Restrictions.like(SC_COLUMN9, obj.getScColumn9(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn10())) {
				criteria.add(Restrictions.like(SC_COLUMN10, obj.getScColumn10(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getZsZxlb())) {
				criteria.add(Restrictions.like(ZS_ZXLB, obj.getZsZxlb(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getInXxbz1())) {
				criteria.add(Restrictions.eq(IN_XXBZ1, obj.getInXxbz1()));
			}
			if (!isEmpty(obj.getInXxbz2())) {
				criteria.add(Restrictions.eq(IN_XXBZ2, obj.getInXxbz2()));
			}
			if (!isEmpty(obj.getInXxbz3())) {
				criteria.add(Restrictions.eq(IN_XXBZ3, obj.getInXxbz3()));
			}
			if (!isEmpty(obj.getInXkkm())) {
				criteria.add(Restrictions.like(IN_XKKM, obj.getInXkkm(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getInYkxkkm())) {
				criteria.add(Restrictions.like(IN_YKXKKM, obj.getInYkxkkm(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getPrintStatus())) {
				criteria.add(Restrictions.eq(PRINT_STATUS, obj.getPrintStatus()));
			}
			//补充
			this.sort(criteria, sort, order);
			
			criteria.setFirstResult(startIndex);
			criteria.setMaxResults(pageSize);
			list = criteria.list();
			session.close();
			return new PageModule(pageNumber, pageSize, countByInstance(obj), list);
		} catch (RuntimeException re) {
			log.error("findByInstance failed", re);
			throw re;
		}
	}
	
	public int countByInstance(final ZsApplyView obj) {
		log.debug("finding the number of ZsApplyView instance");
		try {
			int count = 0;
			Session session = getHibernateTemplate().getSessionFactory().openSession();
			Criteria criteria = session.createCriteria(ZsApplyView.class);

			if (!isEmpty(obj.getUsId())) {
				criteria.add(Restrictions.eq(US_ID, obj.getUsId()));
			}
			if (!isEmpty(obj.getUsBmxh())) {
				criteria.add(Restrictions.like(US_BMXH, obj.getUsBmxh(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsName())) {
				String name = AESUtils.AESEncryptDemo(obj.getUsName());
				criteria.add(Restrictions.eq(US_NAME, name));
			}
			if (!isEmpty(obj.getInXb())) {
				criteria.add(Restrictions.like(IN_XB, obj.getInXb(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsNo())) {
				criteria.add(Restrictions.like(US_NO, obj.getUsNo(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsIdcard())) {
				criteria.add(Restrictions.like(US_IDCARD, obj.getUsIdcard(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getUsPassword())) {
				criteria.add(Restrictions.eq(US_PASSWORD, obj.getUsPassword()));
			}
			if (!isEmpty(obj.getUsEmail())) {
				criteria.add(Restrictions.eq(US_EMAIL, obj.getUsEmail()));
			}
			if (!isEmpty(obj.getUsMobile())) {
				criteria.add(Restrictions.eq(US_MOBILE, obj.getUsMobile()));
			}
			if (!isEmpty(obj.getOpenId())) {
				criteria.add(Restrictions.eq(OPEN_ID, obj.getOpenId()));
			}
			if (!isEmpty(obj.getWxName())) {
				criteria.add(Restrictions.eq(WX_NAME, obj.getWxName()));
			}
			if (!isEmpty(obj.getWxIcon())) {
				criteria.add(Restrictions.eq(WX_ICON, obj.getWxIcon()));
			}
			if (!isEmpty(obj.getUsActive())) {
				criteria.add(Restrictions.eq(US_ACTIVE, obj.getUsActive()));
			}
			if (!isEmpty(obj.getUsYun())) {
				criteria.add(Restrictions.eq(US_YUN, obj.getUsYun()));
			}
			if (null != obj.getYear()) {
				criteria.add(Restrictions.eq(YEAR, obj.getYear()));
			}
			if (!isEmpty(obj.getAppStatus())) {
				criteria.add(Restrictions.eq(APP_STATUS, obj.getAppStatus()));
			}
			if (!isEmpty(obj.getSendStatus())) {
				criteria.add(Restrictions.eq(SEND_STATUS, obj.getSendStatus()));
			}
			if (!isEmpty(obj.getCheckStatus())) {
				criteria.add(Restrictions.eq(CHECK_STATUS, obj.getCheckStatus()));
			}
			if (!isEmpty(obj.getPayStatus())) {
				criteria.add(Restrictions.eq(PAY_STATUS, obj.getPayStatus()));
			}
			if (!isEmpty(obj.getPassStatus())) {
				criteria.add(Restrictions.eq(PASS_STATUS, obj.getPassStatus()));
			}
			if (!isEmpty(obj.getLocalStatus())) {
				criteria.add(Restrictions.eq(LOCAL_STATUS, obj.getLocalStatus()));
			}
			if (!isEmpty(obj.getFileStatus())) {
				criteria.add(Restrictions.eq(FILE_STATUS, obj.getFileStatus()));
			}
			if (!isEmpty(obj.getFileCheckStatus())) {
				criteria.add(Restrictions.eq(FILE_CHECK_STATUS, obj.getFileCheckStatus()));
			}
			if (!isEmpty(obj.getTestNo())) {
				criteria.add(Restrictions.like(TEST_NO, obj.getTestNo(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getTestNum())) {
				criteria.add(Restrictions.like(TEST_NUM, obj.getTestNum(),MatchMode.ANYWHERE));
			}
			if (null != obj.getExId()) {
				criteria.add(Restrictions.eq(EX_ID, obj.getExId()));
			}
			if (!isEmpty(obj.getColumn1())) {
				criteria.add(Restrictions.eq(COLUMN1, obj.getColumn1()));
			}
			if (!isEmpty(obj.getColumn2())) {
				criteria.add(Restrictions.eq(COLUMN2, obj.getColumn2()));
			}
			if (!isEmpty(obj.getColumn3())) {
				criteria.add(Restrictions.eq(COLUMN3, obj.getColumn3()));
			}
			if (!isEmpty(obj.getColumn4())) {
				criteria.add(Restrictions.eq(COLUMN4, obj.getColumn4()));
			}
			if (!isEmpty(obj.getColumn5())) {
				criteria.add(Restrictions.eq(COLUMN5, obj.getColumn5()));
			}
			if (!isEmpty(obj.getColumn6())) {
				criteria.add(Restrictions.eq(COLUMN6, obj.getColumn6()));
			}
			if (!isEmpty(obj.getColumn7())) {
				criteria.add(Restrictions.eq(COLUMN7, obj.getColumn7()));
			}
			if (!isEmpty(obj.getColumn8())) {
				criteria.add(Restrictions.eq(COLUMN8, obj.getColumn8()));
			}
			if (!isEmpty(obj.getColumn9())) {
				criteria.add(Restrictions.eq(COLUMN9, obj.getColumn9()));
			}
			if (!isEmpty(obj.getColumn10())) {
				criteria.add(Restrictions.eq(COLUMN10, obj.getColumn10()));
			}
			if (!isEmpty(obj.getInLxdh())) {
				criteria.add(Restrictions.eq(IN_LXDH, obj.getInLxdh()));
			}
			if (!isEmpty(obj.getInLxdh2())) {
				criteria.add(Restrictions.eq(IN_LXDH2, obj.getInLxdh2()));
			}
			if (!isEmpty(obj.getInZymc01())) {
				criteria.add(Restrictions.eq(IN_ZYMC01, obj.getInZymc01()));
			}
			if (!isEmpty(obj.getInZymc02())) {
				criteria.add(Restrictions.eq(IN_ZYMC02, obj.getInZymc02()));
			}
			if (!isEmpty(obj.getInZymc03())) {
				criteria.add(Restrictions.eq(IN_ZYMC03, obj.getInZymc03()));
			}
			if (!isEmpty(obj.getInZymc04())) {
				criteria.add(Restrictions.eq(IN_ZYMC04, obj.getInZymc04()));
			}
			if (!isEmpty(obj.getInZymc05())) {
				criteria.add(Restrictions.eq(IN_ZYMC05, obj.getInZymc05()));
			}
			if (!isEmpty(obj.getInZymc06())) {
				criteria.add(Restrictions.eq(IN_ZYMC06, obj.getInZymc06()));
			}
			if (!isEmpty(obj.getInZymc07())) {
				criteria.add(Restrictions.eq(IN_ZYMC07, obj.getInZymc07()));
			}
			if (!isEmpty(obj.getInZymc08())) {
				criteria.add(Restrictions.eq(IN_ZYMC08, obj.getInZymc08()));
			}
			if (!isEmpty(obj.getInZymc09())) {
				criteria.add(Restrictions.eq(IN_ZYMC09, obj.getInZymc09()));
			}
			if (!isEmpty(obj.getInZymc10())) {
				criteria.add(Restrictions.eq(IN_ZYMC10, obj.getInZymc10()));
			}
			if (!isEmpty(obj.getScColumn1())) {
				criteria.add(Restrictions.like(SC_COLUMN1, obj.getScColumn1(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn2())) {
				criteria.add(Restrictions.like(SC_COLUMN2, obj.getScColumn2(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn3())) {
				criteria.add(Restrictions.like(SC_COLUMN3, obj.getScColumn3(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn4())) {
				criteria.add(Restrictions.like(SC_COLUMN4, obj.getScColumn4(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn5())) {
				criteria.add(Restrictions.like(SC_COLUMN5, obj.getScColumn5(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn6())) {
				criteria.add(Restrictions.like(SC_COLUMN6, obj.getScColumn6(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn7())) {
				criteria.add(Restrictions.like(SC_COLUMN7, obj.getScColumn7(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn8())) {
				criteria.add(Restrictions.like(SC_COLUMN8, obj.getScColumn8(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn9())) {
				criteria.add(Restrictions.like(SC_COLUMN9, obj.getScColumn9(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getScColumn10())) {
				criteria.add(Restrictions.like(SC_COLUMN10, obj.getScColumn10(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getZsZxlb())) {
				criteria.add(Restrictions.like(ZS_ZXLB, obj.getZsZxlb(),MatchMode.ANYWHERE));
			}
			if (!isEmpty(obj.getInXxbz1())) {
				criteria.add(Restrictions.eq(IN_XXBZ1, obj.getInXxbz1()));
			}
			if (!isEmpty(obj.getInXxbz2())) {
				criteria.add(Restrictions.eq(IN_XXBZ2, obj.getInXxbz2()));
			}
			if (!isEmpty(obj.getInXxbz3())) {
				criteria.add(Restrictions.eq(IN_XXBZ3, obj.getInXxbz3()));
			}
			if (!isEmpty(obj.getPrintStatus())) {
				criteria.add(Restrictions.eq(PRINT_STATUS, obj.getPrintStatus()));
			}
			//补充
			count = (Integer) criteria.setProjection(Projections.rowCount()).uniqueResult();
			session.close();
			return count;
		} catch (RuntimeException re) {
			log.error("find the number of ZsApplyView instance failed", re);
			throw re;
		}
	}
	
	@SuppressWarnings("unchecked")
	public List findByHql(final int pageNumber ,final int pageSize, final String hql, final Object[] values){
		log.debug("finding ZsApplyView instance by hql");
	    return (List<ZsApplyView>) super.getHibernateTemplate().execute(new HibernateCallback(){
	        public Object doInHibernate(Session session) throws HibernateException, SQLException {
	            Query query=session.createQuery(hql);
	            if (values != null) {// 为hql语句传入参数
					for (int i = 0; i < values.length; i++) {
						query.setParameter(i, values[i]);
					}
				}
	            return query.setFirstResult((pageNumber-1)*pageSize).setMaxResults(pageSize).list();
	        }
	    });
	}

	@SuppressWarnings("unchecked")
	public int findCountByHql(final String hql, final Object[] values) {
		log.debug("finding the number of ZsApplyView instance");
		try {
			return (Integer) super.getHibernateTemplate().execute(new HibernateCallback(){
		        public Object doInHibernate(Session session) throws HibernateException, SQLException {
		            Query query=session.createQuery(hql);
		            if (values != null) {// 为hql语句传入参数
						for (int i = 0; i < values.length; i++) {
							query.setParameter(i, values[i]);
						}
					}
					return ((Long)query.uniqueResult()).intValue();
		        }
		    });
		} catch (RuntimeException re) {
			log.error("find the number of ZsApplyView instance failed", re);
			throw re;
		}
	}
	
	private boolean isEmpty(String value) {
		if (value==null || value.trim().length()==0) {
			return true;
		}
		return false;
	}
}